<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class obgyne_directory extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function __construct() {
		parent::__construct();
		ini_set('session.cookie_httponly',1); 
		ini_set('session.use_only_cookies',1);
		$this->load->model('obgyne_directory_class');
		$this->load->model('obgyne_dir_info_class');
	} 
	public function save_obgyne_dir(){
		$post = $this->input->post();
		$message = '';
		$obgyne_directory = $this->obgyne_directory_class->get_obgyne_dir($post);
		if($obgyne_directory!=0){
			$message = $this->obgyne_directory_class->update($post);
		} else {
			$message = $this->obgyne_directory_class->insert($post);
		}
		echo json_encode($message);		
	} 	 
	public function get_list_obgyne_directory(){
		$data=array();
		
		$obgyne_directory = $this->obgyne_directory_class->list_obgyne_directory();
		if($obgyne_directory!=0){
			foreach($obgyne_directory as $key=>$value){
				$data['intID'][$key]=$value['intID'];	
				$data['intUserID'][$key]=$value['intUserID'];
				$post['intID']=$value['intID'];
				$info = $this->obgyne_dir_info_class->obgyne_dir_info($post);
				if($info!=0){
					$data['strLocation'][$key]=$info['strLocation'];
					$data['strDays'][$key]=$info['strDays'];
					$data['strTime'][$key]=$info['strTime'];
				}
				$data['strSalutation'][$key]=$value['strSalutation'];		
				$data['strName'][$key]=$value['strName'];		
			}
		}
		echo json_encode($data);
	}
	
	public function get_obgyne_dir(){
		$post = $this->input->post();
		$obgyne_directory = $this->obgyne_directory_class->get_obgyne_dir($post);
		if($obgyne_directory!=0){
			$data['intID'] = $obgyne_directory['intID'];
			$data['strName'] = $obgyne_directory['strName'];
		}
		$obgyne_dir_info = $this->obgyne_dir_info_class->obgyne_dir_info($post);
		if($obgyne_dir_info!=0){
			$data['intOBDirectoryID'] = $obgyne_dir_info['intOBDirectoryID'];
			$data['strLocation'] = $obgyne_dir_info['strLocation'];
			$data['strTime'] = $obgyne_dir_info['strTime'];
			$data['strDays'] = $obgyne_dir_info['strDays'];
		}
		echo json_encode($data);
	}
	public function delete_obgyne_dir(){
		$post = $this->input->post();
		$obgyne_directory = $this->obgyne_directory_class->delete($post);
		echo json_encode($obgyne_directory);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */